package com.cy.cykh.app.viewmodel

import android.app.Application
import android.arch.lifecycle.AndroidViewModel
import android.arch.lifecycle.MutableLiveData
import com.cy.cykh.app.http.CdyApi
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers


/**
 * @author Administrator
 * @FileName
 * @date 2019/1/4 17:20
 */
class OtherViewModel(app: Application)  : AndroidViewModel(app) {
    private var  api: CdyApi? = null

    val loadStatusLiveData: MutableLiveData<String> = MutableLiveData()


    fun loadPublishedDate(){
        api= CdyApi.create()
        api!!.getHistory()
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .doOnError(Throwable::printStackTrace)
                .subscribe { result ->
                    loadStatusLiveData.value=result.string()
                }
    }

}